var pn = 1;
var str = "";
var arr = [];
$.ajax({
	type: "get",
	url: "../getTeamDate.json",
	data: {
		aid: "3c2c1673f45c4c7f9f7611006f998fe3",
		ps: "10",
		pn: pn
	},
	dataType: "json",
	success: function(rsp){
		for (var i = 0; i < rsp.list.length; i++) {
			var logUrl = rsp.list[i].icon.split(",")[0];
			var name = rsp.list[i].name.split(",")[0];
			str += '<li><div class="li_left"><span class="teamLog"><img src="' + logUrl +
			'"/></span><a href="###">' + name +
			'</a></div><div class="subState"><input type="checkbox" id="' + rsp.list[i].id +
			'" class="check" checked="checked" value="false"/><label for="' + rsp.list[i].id +
			'" class="labsub"></label></div></li>';
			arr[i] = rsp.list[i].type;
		}
		$(".ullist").html(str);
		changeState();
		myscroll.refresh();

	}
});

function changeState() {
	/* 初始化iscroll */
	/* 解决click延迟   */
	window.addEventListener('load', function() {
		FastClick.attach(document.body);
	}, false);
	
	var oSubState = document.getElementsByClassName("subState");
	var oCheck = document.getElementsByClassName("check");
	var oLabsub = document.getElementsByClassName("labsub");
	
	
	for (var i = 0; i < oCheck.length; i ++) {
		oCheck[i].index = i;
		oCheck[i].value = arr[i];
		if(oCheck[i].value == "true"){
			$(".subState").eq(i).addClass("subBg");
			$(".labsub").eq(i).addClass("labmove");
		}
		
		oCheck[i].onclick = function() {
			if(!this.checked) {
				$(".subState").eq(this.index).addClass("subBg");
				$(".labsub").eq(this.index).addClass("labmove");
			}else {
				$(".subState").eq(this.index).removeClass("subBg");
				$(".labsub").eq(this.index).removeClass("labmove");
			}
		}
	}
}

